import { createSSRApp, nextTick } from "vue"
import App from "./App.vue";
// 工具类
import utils from "@/utils/utils"
// uView组件库
import uviewPlus from 'uview-plus'
// 导入 pinia 实例
import pinia from './store'

import {config} from "@/config/config"

export function createApp() {
  const app = createSSRApp(App);
  // @ts-ignore
  app.use(uviewPlus, () => {
    return {
      options: {
        config: {
          unit: 'rpx',
          // 全局拦截示例
          interceptor: {
            navbarLeftClick: () => {
              console.log('全局拦截 navbarLeftClick')
            }
          }
        },
        // ✅ props 默认值修改都放这里！
        props: {
          // 示例：修改 alert 组件默认类型
          alert: {
            type: 'error'
          },
          // 示例：修改 button 的默认大小
          button: {
            size: 'large'
          }
        }
      }
    }
  })

  app.use(pinia)
  app.config.globalProperties.$utils = utils
  app.config.globalProperties.$imageUrl = config.imageUrl
  return {
    app,
  };
}
